package com.bowen.demo.demo004;

import org.apache.commons.lang.StringUtils;

/**
 * <h3>java-study</h3>
 * <p>给身份证电话号码加****星号加以保护</p>
 * @author : zhang.bw
 * @date : 2021-03-10 12:41
 **/
public class CodeUtils {

	/**
	 * 用户身份证号码的打码隐藏加星号加*
	 * @return 处理完成的身份证
	 */
	public static String idCardMask(String idCardNum) {
		String res = "";
		if (!StringUtils.isEmpty(idCardNum)) {
			StringBuilder stringBuilder = new StringBuilder(idCardNum);
			res = stringBuilder.replace(6, 14, "********").toString();
		}
		return res;
	}

	/**
	 * 用户电话号码的打码隐藏加星号加*
	 * @return 处理完成的身份证
	 */
	public static String phoneMask(String phone) {
		String res = "";
		if (!StringUtils.isEmpty(phone)) {
			StringBuilder stringBuilder = new StringBuilder(phone);
			res = stringBuilder.replace(3, 7, "****").toString();
		}
		return res;
	}
}
